package cn.virens.web.components.beetl.fun;

import org.beetl.core.Context;
import org.beetl.core.Function;

import cn.hutool.core.util.StrUtil;

public class MenuIdentityFunction implements Function {

	@Override
	public String call(Object[] paras, Context ctx) {
		if (paras == null || paras.length < 2) { return "none"; }

		// 第一个参数为完整标识
		// 第二个参数为检查标识
		String identityAll = String.valueOf(paras[0]);
		String identityCehck = String.valueOf(paras[1]);

		// 判断当前节点是否选中
		boolean isIdentity = StrUtil.startWithIgnoreCase(identityAll, identityCehck);
		if (paras.length > 2) {
			return isIdentity ? "layui-nav-itemed" : "none";
		} else {
			return isIdentity ? "layui-this" : "none";
		}
	}

}
